Making your own palettes

With a little bit of programming you can create your own palettes with your frequently used menu items in the two HTML menus. What you need to do is the following:

A palette is created by first defining a menu. This is done with code like this

menu -n "Palette title" -m -p myPaletteProc {
    "Button text 1"
    "Button text 2"
}

You can of course add as many buttons as you like. myPaletteProc is the function which will be called when you click a button. It is called with two arguments, the first is the palette title and the second is the button text. To attach each button to a menu item in one of the two HTML menus myPaletteProc has to be defined like this:

proc myPaletteProc {themenu theitem} {
    switch $theitem {
        "Button text 1" {htmlMenuItem "submenu" "menu item"}
        "Button text 2" {htmlMenuItem "submenu" "menu item"}
    }
}

submenu is here a submenu of one of the HTML menus and menu item is the menu item in the submenu you want the button to be attached to. In this example the first argument "themenu" of myPaletteProc is never used, but it has to be there since Alpha sends two arguments to myPaletteProc.

As an explicit example we create a palette with two buttons attached to "Table Template" and "Insert Paragraphs". The menu defining the palette is

menu -n "My palette" -m -p myPaletteProc {
    "Table Template"
    "Insert Paragraphs"
}

Two things to notice:

The function myPaletteProc should in our example be define as

proc myPaletteProc {themenu theitem} {
    switch $theitem {
        "Table Template" {htmlMenuItem "Tables" "Table Template"}
        "Insert Paragraphs" {htmlMenuItem "Blocks and Dividers" "Insert Paragraphs"}
    }
}

One important detail is that if a menu item ends by ... this trailing ... must be omitted as was done in htmlMenuItem "Tables" "Table Template".

What about if we want one of the menu items at top level in the two HTML menus? To clarify this we extend the example by adding two more buttons to the palette:

menu -n "My palette" -m -p myPaletteProc {
    "Table Template"
    "Insert Paragraphs"
    "New Document"
    "Colors"
}

proc myPaletteProc {themenu theitem} {
    global htmlMenu htmlUtilsMenu
    switch $theitem {
        "Table Template" {htmlMenuItem "Tables" "Table Template"}
        "Insert Paragraphs" {htmlMenuItem "Blocks and Dividers" "Insert Paragraphs"}
        "New Document" {htmlMenuItem $htmlMenu "New Document"}
        "Colors" {htmlMenuItem $htmlUtilsMenu "Colors"}
    }
}

To refer to the two HTML menus we use the variables htmlMenu and htmlUtilsMenu in the way shown above. First we add the line

    global htmlMenu htmlUtilsMenu

and then we write $htmlMenu when we want the HTML menu and $htmlUtilsMenu when we want the HTML Utilities menu.

This code defining your palette(s) should be put in your HTML prefs file. When you are in HTML mode open it using Config -> Current Mode - > Edit Prefs File.

Ok, we have now defined a palette but how do we open it? For this to be possible we have to add one line to the global prefs file. Open the global prefs file by using Config -> Global -> Edit Prefs File. The line to add is

set customHTMLpalettes {"Palette title 1" "Palette title 2"}

where "Palette title 1" etc. are the titles of your palettes. In our example we would have added the line

set customHTMLpalettes {"My palette"}

The reason that this line has to be in the global prefs file is that is has to be loaded before HTML mode.

The next time you launch Alpha you will now get an extra submenu in the HTML menu called Palettes where the menu items are the titles of your palettes.

One last detail to make sure things work. Alpha saves the HTML menu definition in a file called "HTML menu cache" in Alpha's folder inside your Preferences folder. Trash this file after you have defined your palettes, otherwise you will not get this extra submenu. If you trash this file Alpha will create a new one which includes the Palettes menu.

Selecting a menu item in the 'Palettes' menu opens the palette. These palettes are such that they disappear when you leave HTML mode and reappear when you go back to HTML mode. This behavior is the same as when you pull off one of the two HTML menus, but unfortunately not when you pull off a submenu.